package com.xlh.server.protocol.support.json;

import com.xlh.Utils.FUti;
import com.xlh.Utils.GsonManager;
import com.xlh.adapter.FloatRightButListAdapter;
import com.xlh.bean.ProBean;
import com.xlh.bean.ProtocolObject.EnvObjectsStateAttr;
import com.xlh.bean.ProtocolObject.ParamObject.LabelParam;
import com.xlh.bean.ProtocolObject.RightFiexButsBean;
import com.xlh.bean.TitleBean;
import com.xlh.interf.IActivity;
import com.xlh.interf.ITakeMessage;

import java.util.ArrayList;
import java.util.List;

/**
 * 右边浮动按钮
 * Created by mike@Q184377367 on 2018/7/2.
 */

public class RightFiexButsServer implements ITakeMessage {

    private IActivity atv;
    private String hasType = "rightFiexButs";
    private RightFiexButsBean protccoObj;

    public RightFiexButsServer(IActivity atv){
        this.atv = atv;


    }

    @Override
    public void takeMessage(String t,String s){

        if(!t.equals(this.hasType)) return;

        protccoObj =  GsonManager.gsmgr.jsonToAnyObject(s, RightFiexButsBean.class);

        if(protccoObj==null) return;
        this.renderView();

    }

    public void renderView(){



        this.atv.getActivity().getFloatRightButListViewManager().getDataAdapter().clear();
        for(LabelParam e: this.protccoObj.getButs()){
            TitleBean data = new TitleBean();
            data.setmText(e.getLabel());
            data.setmAction(e.getCmd());
            this.atv.getActivity().getFloatRightButListViewManager().getDataAdapter().addData(data);
        }

        this.atv.getActivity().getFloatRightButListViewManager().getDataAdapter().update();







    }


    @Override
    public boolean takeMessage(String s) {
        return false;
    }

    @Override
    public void init() {

    }

    @Override
    public void atViewLoadAfterInit() {

    }

}
